#ifndef TBUFFER_H
#define TBUFFER_H

#include "Config/Export.h"
#include "Core/IBufferBase.h"
#include <cstring>

namespace blue {

template <GLenum target>
class SHARED TBuffer : public IBufferBase
{
    public:

        TBuffer(GLsizei size, int nbDeclarations = 1, GLenum mode = GL_STATIC_DRAW_ARB);
        virtual ~TBuffer();

        virtual GLsizei getSize() const;
        virtual GLenum getType() const;
        virtual GLenum getMode() const;
        virtual GLuint getBuffer() const;
        virtual int getNbDeclarations() const;
        virtual const VertexDeclaration &getDeclaration(int nb) const;

        void fill(GLsizeiptr size, const GLvoid *data, GLenum usage, GLsizei size_b);
        void update(GLsizeiptr size, const GLvoid *data);

    private:

        GLsizei _size;
        int _nbDeclarations, _inc;
        GLenum _mode;
        GLuint _buf;
        VertexDeclaration *_VDs;

};

typedef TBuffer<GL_ARRAY_BUFFER> VertexBuffer;
typedef TBuffer<GL_ELEMENT_ARRAY_BUFFER> IndexBuffer;

#include "TBuffer.inl"

}

#endif

